﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IntelligentDecisioning.SharePoint.Definition;
using Microsoft.SharePoint;
using IntelligentDecisioning.SharePoint.BusinessEntities;
using Microsoft.Practices.SPG.Common.ListRepository;
using IntelligentDecisioning.SharePoint.Helpers;
using IntelligentDecisioning.SharePoint.Definition.Lists;

namespace IntelligentDecisioning.SharePoint.Definitions
{
    public class DemonstrationProjectTaskList : SharePointList 
    {

        public DemonstrationProjectTaskList()
            :base("Demo Project Task List")
        {
           
        }



        public List<DemonstrationProjectTaskEntity> GetTasks(SPWeb targetWeb)
        {
            ListItemFieldMapper<DemonstrationProjectTaskEntity> entityFieldMapper = new ListItemFieldMapper<DemonstrationProjectTaskEntity>();
            entityFieldMapper.FieldMappings = GetFieldMappings();

            List<DemonstrationProjectTaskEntity> tasks = new List<DemonstrationProjectTaskEntity>();
            IDListHelper listHelper = new IDListHelper(targetWeb.Site, targetWeb);
            SPList demonstrationTaskList = listHelper.GetList(Name);
    
            foreach (SPListItem item in demonstrationTaskList.Items)
            {
                DemonstrationProjectTaskEntity demonstrationTaskEntity = entityFieldMapper.CreateEntity(item);
                tasks.Add(demonstrationTaskEntity);
            }

            return tasks;
        }
    }
}
